-------------------------------------------------------------
 KerbTrack
 Authors:   pizzaoverhead
 Version:   1.6
 Released:  2024-07-08
 KSP:       v1.12.5

 Thread:    https://forum.kerbalspaceprogram.com/topic/66352-141-kerbtrack-v15-head-tracking-using-your-webcam-trackir-oculus-rift-joystick-2018-03-14/
 Licence:   GNU v2, http://www.gnu.org/licenses/gpl-2.0.html
 Source:    https://github.com/FirstPersonKSP/KerbTrack
-------------------------------------------------------------

KerbTrack allows controlling the game camera by looking around using your head. This can be done via TrackIR, webcam, DIY point tracker LEDs, gamepad, or anything that can pretend to be a joystick.

To install KerbTrack, extract the contents of the zip to the root KSP folder, next to KSP.exe, merging with the GameData folder. Harmony is a required dependency. Install it from here: https://github.com/KSPModdingLibs/HarmonyKSP/releases
To change the settings in-game, pause the game with Esc during a flight, and a new window will appear. You can test out your tracker's movement even while the game is paused. By default, the Scroll Lock key enables and disables the tracker. The tracker will disable itself if it encounters an error, so check that it is enabled at the top of the window if you don't see any movement.


Dependencies
------------
https://github.com/KSPModdingLibs/HarmonyKSP/releases


Quick start guide - webcam
--------------------------
You will need a webcam (even an old one should work, e.g. the PlayStation Eye, install details here: https://github.com/opentrack/opentrack/wiki/PS3-Eye-open-driver-instructions).
Install KerbTrack.
Install the latest release of opentrack: https://github.com/opentrack/opentrack/releases.
Download the latest pre-release of aitrack, and extract it to a folder somewhere (not in the KSP directory).
Make sure your webcam is plugged in.
Run aitrack.exe inside the aitrack folder.
Press "Start tracking" and you should see a view from your webcam with pink dots around your face.
Start opentrack.
Set opentrack's input to "UDP over network", and its output to "freetrack 2.0 Enhanced".
Face forwards and click "Start" in opentrack. You should see "no video", and the pink octopus should move when you move your head.
Run KSP and go to any craft in flight or on the launchpad.
Pause the game, and the KerbTrack window will appear.
Under Tracker Settings, make sure TrackIR is selected, and the top of the window says "Enabled (ScrollLock)". If it's disabled, press the Scroll Lock key on your keyboard to enable it.
You should now be able to look around using your head in flight, IVA and the map view.

Every time you want to use webcam tracking with KSP, you need to run aitrack, "Start tracking", run opentrack, "Start".
Once you have head tracking working above, this setup works with lots of other games too: https://beam.eyeware.tech/games-opentrack-webcam-head-tracking-software/


Tracker descriptions
--------------------
TrackIR/opentrack
-----------------
Supports TrackIR (https://www.trackir.com/) and other systems which emulate it, such as opentrack (https://github.com/opentrack/opentrack/releases).
When using opentrack, select TrackIR as the tracker in KerbTrack. In opentrack, set the Input tracker appripriate to your hardware setup, and select "freetrack 2.0 Enhanced" as the Output.In the Output settings, ensure "Use TrackIR" or "Enable both" is selected.
Thanks to Stilton and Medsouz for their contributions to adding TrackIR support.

Joystick
--------
Joystick mode can be used to assign the axes of a joystick or gamepad to camera orientation. This can also be used in conjunction with headtrackers not directly supported by KerbTrack by setting the head tracker to operate as a virtual joystick. Press Escape during the game to pause, bringing up the setup menu, and select "Joystick" mode. The menu then allows configuring which joystick to use and which axis to assign to which direction.

opentrack UDP
-------------
This tracker receives tracking data over the network using the opentrack UDP protocol on port 4242. It's often better to use the TrackIR setting and run opentrack with Input set to "UDP over network" instead of this, as opentrack smooths out shaky tracking.


Contributors
------------
Stilton
Medsouz
Unit327
JonnyOThan


Version history
---------------
1.6 (2024-07-08)
- Updated for KSP 1.12.5.
- Moved UI to toolbar.
- Fixed saving settings.
- Fixed Linux support and axis inversion. (thanks to Unit327 for this)
- Fixed movement joystick in flight view orbit camera and in map view.
- Added button to reset sliders to default.
- Set up defaults for gamepad.
- Improved the UI.

1.5 (2018-03-14)
- Updated for KSP 1.4.1.
- Added support for opentrack.
- Added position axes to joystick tracker.
- Added description text for trackers.
- Removed defunct trackers: use opentrack with the TrackIR setting, or set your tracker to output to the Joystick setting.

1.4 (2017-03-12)
- Updated for KSP 1.2.2.
- Added improved handling for TrackIR errors.
- Improved accuracy for position scale editor.
- Updated GUI.

1.3 (2016-10-24)
- Updated for KSP 1.2.
- Added FTNoIR zeroed data fix (thanks to @DaMichel for this).
- Changed logging to use [KerbTrack] to take advantage of the new KSP log colorising system.

1.2 (2015-08-09)
- Added support for joystick control.

1.1.3 (2015-08-09)
- Fixed Oculus Rift quaternion tracker.
- Upgraded to OVR SDK 0.6.0.1.

1.1.2 (2014-10-16)
- Fixed persistence for scene toggles.

1.1.1 (2014-10-13)
- Added Add-on Version Checker support.
- Added missing files.

1.1 (2014-10-13)
- Added support for FeepingCreature's IQuatTracker for more accurate Oculus Rift tracking.
- Added the ability to disable tracking in external and map views.

1.0 (2014-09-13)
- First full release.
- Added support for TrackIR and the Oculus Rift.

0.1 (2014-03-27)
- Initial alpha release.